export const userRetentionOpts = {
  data() {
    return {
      pickerMinDate: '',
      datePickerOpt: {
        onPick: ({ maxDate, minDate }) => {
          this.pickerMinDate = minDate.getTime();
          if (maxDate) {
            this.pickerMinDate = '';
          }
        },
        disabledDate: (time) => {
          if (this.pickerMinDate !== '') {
            const one = 30 * 24 * 3600 * 1000;
            const minTime = this.pickerMinDate - one;
            let maxTime = this.pickerMinDate + one;
            if (maxTime > new Date()) {
              maxTime = new Date();
            }
            return time.getTime() < minTime || time.getTime() > maxTime;
          }
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: '本周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              const days = new Date().getDay() == 1 ? 0 : new Date().getDay() - 1;
              start.setTime(start.getTime() - 3600 * 1000 * 24 * days);
              picker.$emit('pick', [start, end]);
            }
          },
          {
            text: '本月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setDate(1); // 本月1日
              picker.$emit('pick', [start, end]);
            }
          },
          {
            text: '最近7天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
              picker.$emit('pick', [start, end]);
            }
          },
          {
            text: '最近15天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 14);
              picker.$emit('pick', [start, end]);
            }
          },
          {
            text: '最近30天',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 29);
              picker.$emit('pick', [start, end]);
            }
          }
        ]
      }
    };
  },
  computed: {
    dateTypeOpt: () => {
      return {
        '按天显示': 1,
        '按周显示': 2,
        '按月显示': 3
      };
    },
    userSelectTypeOpt: () => {
      return {
        '新增用户': 4,
        '活跃用户': 3,
        '新增会员': 2,
        '活跃会员': 1
      };
    },
    keepOrLeaveOpt: () => {
      return {
        '留存': 1,
        '流失': 2
      };
    },
    analyzeModelOpt: () => {
      return {
        '30日': '30day',
        '4周': '4week',
        '12周': '12week',
        '6月': '6month',
        '12月': '12month'
      };
    },
    langOpt: () => {
      return {
        '全部语言': -1,
        '中文': 1,
        '柬文': 2,
        '英文': 3
      };
    },
    platformOpt: () => {
      return {
        '全部渠道': -1,
        '安卓': 1,
        'IOS': 2
      };
    }

  }
};
